package edu.hawaii.duedates;

import com.meterware.httpunit.WebConversation;

/**
 * General Library class for the underlining basis of what is required
 * for dealing with connections, logins and data retrieval.
 * @author Anthony Du
 *
 */
public abstract class Library {
  private String libname;
  private String id, key;
  
  /**
   * Default constructor.
   */
  protected Library() {
    libname = "Some library name";
    id = "0000";
    key = "xxxx";
  }
  /**
   * Library class constructor for initializing the library name.
   * @param name String name of library.
   */
  protected Library(String name) {
    libname = name;
  }
  
  /**
   * Constructor containing library's name and user's credentials.
   * @param name String of library name.
   * @param id String of user id.
   * @param key String of user key.
   */
  protected Library(String name, String id, String key) {
    libname = name;
    this.id = id;
    this.key = key;
  }
  
  /**
   * Sets the name of the library.
   * @param name String name of library
   */
  protected void setLibName(String name) {
    libname = name;
  }
  
  /**
   * Gets the library's name.
   * @return String containing the library's name.
   */
  protected String getLibName() {
    return libname;
  }
  
  /**
   * Get id.
   * @return String containing id.
   */
  protected String getId() {
    return id;
  }
  
  /**
   * Set id.
   * @param id String to set.
   */
  protected void setId(String id) {
    this.id = id;
  }
  
  /**
   * Get key.
   * @return String containing key.
   */
  protected String getKey() {
    return key;
  }
  
  /**
   * Set key.
   * @param key String to set.
   */
  protected void setKey(String key) {
    this.key = key;
  }
  
  /**
   * Authenticate users who attempt to log into library system.
   * @param id String value containing unique ID#.
   * @param key String value containing unique KEY.
   * @return WebConversation object.
   * @exception Exception when error occurs.
   */
  public abstract WebConversation logIntoLibrary(String id, String key) throws Exception;
  
  /**
   * Retrieve data from the library system after successful authentication.
   * @return String containing info regarding users.
   * @exception Exception when error occurs.
   */
  public abstract String getLibInfo() throws Exception;
}
